package org.linlinjava.litemall.db.domain;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;

public class BusinessPerson {
    private String personId;

    private String personName;

    private String personSex;

    private LocalDate personBirthday;

    private String personDepartment;

    private String personLearnLevel;

    private String personSpecial;

    private String personJobTitle;

    private String projectId;

    private String projectName;

    private Integer owningModule;

    private String owningModuleName;

    private Integer personDuty;

    private String personDutyName;

    private Integer personRank;

    private String personRemark;

    private String adminName;

    private LocalDateTime insertTime;

    private String updateAdminName;

    private LocalDateTime updateTime;

    public String getPersonId() {
        return personId;
    }

    public void setPersonId(String personId) {
        this.personId = personId;
    }

    public String getPersonName() {
        return personName;
    }

    public void setPersonName(String personName) {
        this.personName = personName;
    }

    public String getPersonSex() {
        return personSex;
    }

    public void setPersonSex(String personSex) {
        this.personSex = personSex;
    }

    public LocalDate getPersonBirthday() {
        return personBirthday;
    }

    public void setPersonBirthday(LocalDate personBirthday) {
        this.personBirthday = personBirthday;
    }

    public String getPersonDepartment() {
        return personDepartment;
    }

    public void setPersonDepartment(String personDepartment) {
        this.personDepartment = personDepartment;
    }

    public String getPersonLearnLevel() {
        return personLearnLevel;
    }

    public void setPersonLearnLevel(String personLearnLevel) {
        this.personLearnLevel = personLearnLevel;
    }

    public String getPersonSpecial() {
        return personSpecial;
    }

    public void setPersonSpecial(String personSpecial) {
        this.personSpecial = personSpecial;
    }

    public String getPersonJobTitle() {
        return personJobTitle;
    }

    public void setPersonJobTitle(String personJobTitle) {
        this.personJobTitle = personJobTitle;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public Integer getOwningModule() {
        return owningModule;
    }

    public void setOwningModule(Integer owningModule) {
        this.owningModule = owningModule;
    }

    public String getOwningModuleName() {
        return owningModuleName;
    }

    public void setOwningModuleName(String owningModuleName) {
        this.owningModuleName = owningModuleName;
    }

    public Integer getPersonDuty() {
        return personDuty;
    }

    public void setPersonDuty(Integer personDuty) {
        this.personDuty = personDuty;
    }

    public String getPersonDutyName() {
        return personDutyName;
    }

    public void setPersonDutyName(String personDutyName) {
        this.personDutyName = personDutyName;
    }

    public Integer getPersonRank() {
        return personRank;
    }

    public void setPersonRank(Integer personRank) {
        this.personRank = personRank;
    }

    public String getPersonRemark() {
        return personRemark;
    }

    public void setPersonRemark(String personRemark) {
        this.personRemark = personRemark;
    }

    public String getAdminName() {
        return adminName;
    }

    public void setAdminName(String adminName) {
        this.adminName = adminName;
    }

    public LocalDateTime getInsertTime() {
        return insertTime;
    }

    public void setInsertTime(LocalDateTime insertTime) {
        this.insertTime = insertTime;
    }

    public String getUpdateAdminName() {
        return updateAdminName;
    }

    public void setUpdateAdminName(String updateAdminName) {
        this.updateAdminName = updateAdminName;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", personId=").append(personId);
        sb.append(", personName=").append(personName);
        sb.append(", personSex=").append(personSex);
        sb.append(", personBirthday=").append(personBirthday);
        sb.append(", personDepartment=").append(personDepartment);
        sb.append(", personLearnLevel=").append(personLearnLevel);
        sb.append(", personSpecial=").append(personSpecial);
        sb.append(", personJobTitle=").append(personJobTitle);
        sb.append(", projectId=").append(projectId);
        sb.append(", projectName=").append(projectName);
        sb.append(", owningModule=").append(owningModule);
        sb.append(", owningModuleName=").append(owningModuleName);
        sb.append(", personDuty=").append(personDuty);
        sb.append(", personDutyName=").append(personDutyName);
        sb.append(", personRank=").append(personRank);
        sb.append(", personRemark=").append(personRemark);
        sb.append(", adminName=").append(adminName);
        sb.append(", insertTime=").append(insertTime);
        sb.append(", updateAdminName=").append(updateAdminName);
        sb.append(", updateTime=").append(updateTime);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        BusinessPerson other = (BusinessPerson) that;
        return (this.getPersonId() == null ? other.getPersonId() == null : this.getPersonId().equals(other.getPersonId()))
            && (this.getPersonName() == null ? other.getPersonName() == null : this.getPersonName().equals(other.getPersonName()))
            && (this.getPersonSex() == null ? other.getPersonSex() == null : this.getPersonSex().equals(other.getPersonSex()))
            && (this.getPersonBirthday() == null ? other.getPersonBirthday() == null : this.getPersonBirthday().equals(other.getPersonBirthday()))
            && (this.getPersonDepartment() == null ? other.getPersonDepartment() == null : this.getPersonDepartment().equals(other.getPersonDepartment()))
            && (this.getPersonLearnLevel() == null ? other.getPersonLearnLevel() == null : this.getPersonLearnLevel().equals(other.getPersonLearnLevel()))
            && (this.getPersonSpecial() == null ? other.getPersonSpecial() == null : this.getPersonSpecial().equals(other.getPersonSpecial()))
            && (this.getPersonJobTitle() == null ? other.getPersonJobTitle() == null : this.getPersonJobTitle().equals(other.getPersonJobTitle()))
            && (this.getProjectId() == null ? other.getProjectId() == null : this.getProjectId().equals(other.getProjectId()))
            && (this.getProjectName() == null ? other.getProjectName() == null : this.getProjectName().equals(other.getProjectName()))
            && (this.getOwningModule() == null ? other.getOwningModule() == null : this.getOwningModule().equals(other.getOwningModule()))
            && (this.getOwningModuleName() == null ? other.getOwningModuleName() == null : this.getOwningModuleName().equals(other.getOwningModuleName()))
            && (this.getPersonDuty() == null ? other.getPersonDuty() == null : this.getPersonDuty().equals(other.getPersonDuty()))
            && (this.getPersonDutyName() == null ? other.getPersonDutyName() == null : this.getPersonDutyName().equals(other.getPersonDutyName()))
            && (this.getPersonRank() == null ? other.getPersonRank() == null : this.getPersonRank().equals(other.getPersonRank()))
            && (this.getPersonRemark() == null ? other.getPersonRemark() == null : this.getPersonRemark().equals(other.getPersonRemark()))
            && (this.getAdminName() == null ? other.getAdminName() == null : this.getAdminName().equals(other.getAdminName()))
            && (this.getInsertTime() == null ? other.getInsertTime() == null : this.getInsertTime().equals(other.getInsertTime()))
            && (this.getUpdateAdminName() == null ? other.getUpdateAdminName() == null : this.getUpdateAdminName().equals(other.getUpdateAdminName()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getPersonId() == null) ? 0 : getPersonId().hashCode());
        result = prime * result + ((getPersonName() == null) ? 0 : getPersonName().hashCode());
        result = prime * result + ((getPersonSex() == null) ? 0 : getPersonSex().hashCode());
        result = prime * result + ((getPersonBirthday() == null) ? 0 : getPersonBirthday().hashCode());
        result = prime * result + ((getPersonDepartment() == null) ? 0 : getPersonDepartment().hashCode());
        result = prime * result + ((getPersonLearnLevel() == null) ? 0 : getPersonLearnLevel().hashCode());
        result = prime * result + ((getPersonSpecial() == null) ? 0 : getPersonSpecial().hashCode());
        result = prime * result + ((getPersonJobTitle() == null) ? 0 : getPersonJobTitle().hashCode());
        result = prime * result + ((getProjectId() == null) ? 0 : getProjectId().hashCode());
        result = prime * result + ((getProjectName() == null) ? 0 : getProjectName().hashCode());
        result = prime * result + ((getOwningModule() == null) ? 0 : getOwningModule().hashCode());
        result = prime * result + ((getOwningModuleName() == null) ? 0 : getOwningModuleName().hashCode());
        result = prime * result + ((getPersonDuty() == null) ? 0 : getPersonDuty().hashCode());
        result = prime * result + ((getPersonDutyName() == null) ? 0 : getPersonDutyName().hashCode());
        result = prime * result + ((getPersonRank() == null) ? 0 : getPersonRank().hashCode());
        result = prime * result + ((getPersonRemark() == null) ? 0 : getPersonRemark().hashCode());
        result = prime * result + ((getAdminName() == null) ? 0 : getAdminName().hashCode());
        result = prime * result + ((getInsertTime() == null) ? 0 : getInsertTime().hashCode());
        result = prime * result + ((getUpdateAdminName() == null) ? 0 : getUpdateAdminName().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        return result;
    }

    public enum Column {
        personId("person_id", "personId", "VARCHAR", false),
        personName("person_name", "personName", "VARCHAR", false),
        personSex("person_sex", "personSex", "VARCHAR", false),
        personBirthday("person_birthday", "personBirthday", "DATE", false),
        personDepartment("person_department", "personDepartment", "VARCHAR", false),
        personLearnLevel("person_learn_level", "personLearnLevel", "VARCHAR", false),
        personSpecial("person_special", "personSpecial", "VARCHAR", false),
        personJobTitle("person_job_title", "personJobTitle", "VARCHAR", false),
        projectId("project_id", "projectId", "VARCHAR", false),
        projectName("project_name", "projectName", "VARCHAR", false),
        owningModule("owning_module", "owningModule", "INTEGER", false),
        owningModuleName("owning_module_name", "owningModuleName", "VARCHAR", false),
        personDuty("person_duty", "personDuty", "INTEGER", false),
        personDutyName("person_duty_name", "personDutyName", "VARCHAR", false),
        personRank("person_rank", "personRank", "INTEGER", false),
        personRemark("person_remark", "personRemark", "VARCHAR", false),
        adminName("admin_name", "adminName", "VARCHAR", false),
        insertTime("insert_time", "insertTime", "TIMESTAMP", false),
        updateAdminName("update_admin_name", "updateAdminName", "VARCHAR", false),
        updateTime("update_time", "updateTime", "TIMESTAMP", false);

        private static final String BEGINNING_DELIMITER = "`";

        private static final String ENDING_DELIMITER = "`";

        private final String column;

        private final boolean isColumnNameDelimited;

        private final String javaProperty;

        private final String jdbcType;

        public String value() {
            return this.column;
        }

        public String getValue() {
            return this.column;
        }

        public String getJavaProperty() {
            return this.javaProperty;
        }

        public String getJdbcType() {
            return this.jdbcType;
        }

        Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
            this.column = column;
            this.javaProperty = javaProperty;
            this.jdbcType = jdbcType;
            this.isColumnNameDelimited = isColumnNameDelimited;
        }

        public String desc() {
            return this.getEscapedColumnName() + " DESC";
        }

        public String asc() {
            return this.getEscapedColumnName() + " ASC";
        }

        public static Column[] excludes(Column ... excludes) {
            ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
            if (excludes != null && excludes.length > 0) {
                columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
            }
            return columns.toArray(new Column[]{});
        }

        public String getEscapedColumnName() {
            if (this.isColumnNameDelimited) {
                return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
            } else {
                return this.column;
            }
        }

        public String getAliasedEscapedColumnName() {
            return this.getEscapedColumnName();
        }
    }
}